package com.easybuyzjf.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easybuyzjf.mapper.EbProductCategoryMapper;
import com.easybuyzjf.mapper.EbProductMapper;
import com.easybuyzjf.model.EbProduct;
import com.easybuyzjf.model.EbProductCategory;
import org.apache.ibatis.ognl.IntHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service

public class EbProductCategoryService {
    /**
     *
     */
    @Autowired
    private EbProductMapper ebProductMapper;
    @Autowired
    private EbProductCategoryMapper ebProductCategoryMapper;

        public Page<EbProduct> findProductByCate(int psize,int pageSize,int epcId){
            Page<EbProduct> page= new Page(psize,pageSize);

            return ebProductMapper.selectPage(page,new QueryWrapper<EbProduct>()
                    .eq("epc_child_id",epcId));
        }

    //查询所有的大类小类
    public Map<String, List<EbProductCategory>> selectBigAndSmallCate(){

        List<EbProductCategory> bigCates = ebProductCategoryMapper.selectBigCate();
        //TODO 2.查询所有小类

        List<EbProductCategory> smallCates= ebProductCategoryMapper.selectSmallCate();
        Map <String,List<EbProductCategory>> cateMap= new HashMap<>();
        cateMap.put("bigs",bigCates);
        cateMap.put("smalls",smallCates);

        return cateMap;
    }

}
